#ifndef FIR_SEARCHENGINE_H_
#define FIR_SEARCHENGINE_H_

#include "isearchengine.h"
#include "movegenerator.h"
#include "evaluator.h"

class SearchEngine : ISearchEngine {
public:
    SearchEngine();
    ~SearchEngine();

    virtual Move SearchAGoodMove(Byte matrix[15][15], long color);

protected:
    long Negamax(Byte matrix[15][15], long color, long depth, Move& best_move);
    long NegamaxAlphabeta(Byte matrix[15][15], long color, long depth, Move& best_move,
        long alpha, long beta);
    long FailsoftAlphabeta(Byte matrix[15][15], long color, long depth, Move& best_move,
        long alpha, long beta);
    long AspirationSearch();
    long PrincipalVariationSearch();

    inline void MakeMove(Byte matrix[][15], AIMove move);
    inline void UnmakeMove(Byte matrix[][15], AIMove move);
};


inline void SearchEngine::MakeMove( Byte matrix[][15], AIMove move )
{
    matrix[move.y][move.x] = move.color;
}

inline void SearchEngine::UnmakeMove( Byte matrix[][15], AIMove move )
{
    matrix[move.y][move.x] = kNoChess;
}


#endif // FIR_SEARCHENGINE_H_
